package com.tanhua.server.service;

import com.tanhua.dubbo.api.db.UserApi;
import com.tanhua.model.db.User;
import com.tanhua.model.vo.HuanXinUserVo;
import com.tanhua.server.interceptor.UserHolder;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class HuanXinService {

    @DubboReference
    private UserApi userApi;

    /**
     * 环信用户信息
     * @return
     */
    public HuanXinUserVo getHuanXinUser() {
        User user = userApi.findById(UserHolder.getUserId());

        // 构造vo数据  返回
        HuanXinUserVo huanXinUserVo = new HuanXinUserVo();
        huanXinUserVo.setUsername(user.getHxUser());
        huanXinUserVo.setPassword(user.getHxPassword());
        return huanXinUserVo;
    }
}
